package com.tastyshop.service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.tastyshop.dao.MemberMapper;
import com.tastyshop.domain.Member;

@Transactional
@Service
public class MemberServiceImpl implements MemberService{
	
	@Autowired
	private MemberMapper mapper;

	@Override
	public void addMember(Member member) {
		mapper.addMember(member);				
	}

	@Override
	@Transactional(readOnly = true)
	public Member checkEmail(String email) {
		return mapper.checkEmail(email);
	}

	@Override
	@Transactional(readOnly = true)
	public Member emailFind(String mobile) {
		return mapper.emailFind(mobile);
	}

	@Override
	@Transactional(readOnly = true)
	public Member pwdFind(String email) {
		return mapper.pwdFind(email);
	}

	@Override
	@Transactional(readOnly = true)
	public String checkMember(String email) {
		return mapper.checkMember(email);
	}

	@Override
	@Transactional(readOnly = true)
	public String nickNameCheck(String nick_name) {
		return mapper.nickNameCheck(nick_name);
	}

	@Override
	@Transactional(readOnly = true)
	public Member getUserInfo(String email) {
		return mapper.getUserInfo(email);
	}

	@Override
	public void modifyUser(Member member) {
		mapper.modifyUser(member);
	}

	@Override
	public int getIdPwSearch(Map<String, String> map_search) {
		return mapper.getIdPwSearch(map_search);
	}

	@Override
	public void deleteUser(Map<String, String> map_search) {
		mapper.deleteUser(map_search);
		
	}

	@Override
	public void pwdUpdate(Map<String, String> map_search) {
		mapper.pwdUpdate(map_search);
		
	}

	@Override
	public List<Member> getMembersList(String field, String keyword, int page,
			int rows) {
		Map<Object, Object> params = new HashMap<Object, Object>();
		params.put("field", field);
		if(!"".equals(keyword)){
			params.put("keyword", keyword);
		}else{
			params.put("keyword", "");
		}
		params.put("page", page);
		params.put("rows", rows);
		return mapper.getMembersList(params);
	}

	
}
